﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for admin
/// </summary>
public class admin
{
    public admin()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    SqlConnection con1;
    public DataTable LoadUser()
    {
        Connection con = new Connection();
        con1 = new SqlConnection(con.ConnectionString);
        con1.Open();
        string load = " select * from Admin1";
        SqlDataAdapter adap = new SqlDataAdapter(load, con1);
        DataTable dt = new DataTable();
        adap.Fill(dt);
        return dt;
    }

   

    public int Kiemtra(string id, string pass)
    {
        Connection con = new Connection();
        con1 = new SqlConnection(con.ConnectionString);
        con1.Open();
        try
        {
            //SqlCommand Cmd = new SqlCommand("select * from Admin where Email=@id and Pass=@pass", con1);
            SqlCommand Cmd = new SqlCommand("select * from Admin1 where Username=@id and Password=@pass", con1);
            Cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.NVarChar, 20));
            Cmd.Parameters.Add(new SqlParameter("@pass", SqlDbType.NVarChar, 250));
            Cmd.Parameters["@id"].Value = id;
            Cmd.Parameters["@pass"].Value = pass;
            if (Cmd.ExecuteReader().HasRows)
                return 1;
            else
                return 0;
        }
        finally
        {
            //'finally' block is ALWAYS get called.
            con1.Close();
            con1.Dispose();
        }
    }
}
